<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>水平垂直居中</title>
    <style>
      .parent {
        display: table;
        width: 500px;
        height: 500px;
        background-color: #f0f0f0;
      }

      .child {
        display: table-cell;
        vertical-align: middle;
        text-align: center;
      }

      .content {
        width: 100px;
        height: 100px;
        background-color: #3498db;
        display: inline-block;
      }
    </style>
  </head>
  <body>
    <div class="parent">
      <div class="child">
        <div class="content"></div>
      </div>
    </div>
  </body>
</html>
